package net.huashitong.scheduling.service;

import java.util.ArrayList;
import java.util.List;

import net.huashitong.Indicators.databean.CompletionClassificationDatabean;
import net.huashitong.Indicators.entity.CompletionClassification;
import net.huashitong.Indicators.filter.CompletionClassificationFilter;
import net.huashitong.Indicators.service.CompletionClassificationService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PreemptiveService {

	@Autowired
	private CompletionClassificationService classificationService;
	
	public List<CompletionClassification> queryCountyPreemptive(
			CompletionClassificationFilter filter) {
		return classificationService.queryCountyPreemptive(filter);
	}

	public List<CompletionClassificationDatabean> queryPreemptive(
			CompletionClassificationFilter filter) {
		List<CompletionClassification>	classifications = classificationService.queryPreemptive(filter);
		List<CompletionClassificationDatabean> classificationDatabeans = new ArrayList<CompletionClassificationDatabean>();
		for (int i = 0; i < classifications.size(); i++) {
			CompletionClassificationDatabean classificationDatabean = new CompletionClassificationDatabean();
			if(classifications.get(i).getArea().contains("永泰县")){
//				classificationDatabean.setActualCompletionValue(classifications.get(i-1).getActualCompletionValue());
				classificationDatabean.setSpecificIncrease(classifications.get(i+2).getSpecificIncrease());
				classificationDatabean.setArea(classifications.get(i+2).getArea());
				classificationDatabean.setGrowth(classifications.get(i+2).getGrowth());
				classificationDatabeans.add(classificationDatabean);
				classificationDatabean = new CompletionClassificationDatabean();
//				classificationDatabean.setActualCompletionValue(classifications.get(i).getActualCompletionValue());
				classificationDatabean.setSpecificIncrease(classifications.get(i).getSpecificIncrease());
				classificationDatabean.setArea(classifications.get(i).getArea());
				classificationDatabean.setGrowth(classifications.get(i).getGrowth());
				classificationDatabeans.add(classificationDatabean);
				classificationDatabean = new CompletionClassificationDatabean();
//				classificationDatabean.setActualCompletionValue(classifications.get(i+1).getActualCompletionValue());
				classificationDatabean.setSpecificIncrease(classifications.get(i+3).getSpecificIncrease());
				classificationDatabean.setArea(classifications.get(i+3).getArea());
				classificationDatabean.setGrowth(classifications.get(i+3).getGrowth());
				classificationDatabeans.add(classificationDatabean);
			}
		}
		return classificationDatabeans;
	}
	
}
